package com.myapp.youba;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.gson.Gson;
import com.myapp.lvyou.view.adapter.FriendMicroBlogListAdapter;
import com.myapp.youba.basedata.Microblog;
import com.myapp.youba.basedata.MicroblogManager;
import com.myapp.youba.util.YoubaConstant;
import com.myapp.youba.util.YoubaManager;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.ListView;

public class FriendMicroBlogActivity extends Activity {
	private Gson gson = new Gson();
	private  static Context context ;
	private List<Microblog> data = new ArrayList<Microblog>();
	private static ListView lvFriendMicblog;

	private static Handler handler = new Handler() {

		@SuppressWarnings("unchecked")
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 0:
				lvFriendMicblog.setAdapter(new FriendMicroBlogListAdapter(
						context, (List<Microblog>) msg.obj,
						R.layout.list_view_friend_microblog_item,
						new int[] { R.id.tv_microblog_text,
								R.id.tv_microblog_time }));
				break;
			default:
				break;
			}
		}

	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		context=FriendMicroBlogActivity.this;
		setContentView(R.layout.activity_friend_microblog);
		init();
		launth();
		new Thread(new Runnable() {

			@Override
			public void run() {
				String json = YoubaManager.getMicroblogSquareTextAction();
				data = MicroblogManager.getInstance().getMicroblog(json);
				Message msg = new Message();
				msg.obj = data;
				msg.what = 0;
				handler.sendMessage(msg);
			}
		}).start();
	}

	private void init() {
		lvFriendMicblog = (ListView) findViewById(R.id.lv_friend_microblog);

	}

	private void launth() {
	}
}
